package org.sanmao.wyj.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.sanmao.wyj.dao.AdvertisementDao;
import org.sanmao.wyj.domain.Advertisement;
import org.sanmao.wyj.service.AdvertisementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class AdvertisementServiceImpl extends ServiceImpl<AdvertisementDao, Advertisement> implements AdvertisementService {

    @Autowired
    AdvertisementDao advertisementDao;

    @Override
    public Boolean updateAd(Advertisement ad) {
        return advertisementDao.updateById(ad)>0;
    }

    @Override
    public Boolean addAd(Advertisement ad) {
        Date date = new Date(System.currentTimeMillis());
        ad.setTime(date);
        return advertisementDao.insert(ad) > 0;
    }
}
